import 'package:connectivity/connectivity.dart';

class NetworkUtils {
 static void isNetworkConnected({Function connectedCallback}) async {
   isConnected().then((var connected) {
     connectedCallback(connected);
   });
 }

 static Future<bool> isConnected() async {
   var connectivityResult = await (Connectivity().checkConnectivity());
   return connectivityResult != ConnectivityResult.none;
 }

 static Future getConnectedType() async {
   var connectivityResult = await (Connectivity().checkConnectivity());
   if (connectivityResult == ConnectivityResult.mobile) {
     // 网络类型为移动网络
   } else if (connectivityResult == ConnectivityResult.wifi) {
     // 网络类型为WIFI
   }
 }
}
